ALL=cs amdahl ci testpf testpf2

CLS=`getconf LEVEL1_DCACHE_LINESIZE`

all: $(ALL)

testpf2: pftest2.o misc.o
	$(CC) -O0 -Wall $^ -o $@

testpf: pftest.o misc.o
	$(CC) $^  -o $@

cs: cs_test.o task.o misc.o queue.o cal.o
	$(CC) $^ -g -lpthread -o $@

amdahl: amdahl.o task.o misc.o cal.o mcs_spinlock.o
	$(CC) $^ -g -lpthread -o $@

ci: ci.o misc.o cal.o
	$(CC) $^ -g -o $@

OBJS=cs_test.o task.o misc.o cal.o amdahl.o ci.o mcs_spinlock.o pftest.o pftest2.o

CFLAGS=-MMD -g -Wall -D_GNU_SOURCE 
pftest.o: CFLAGS+=-DCACHE_LINE_SIZE=$(CLS) -DPREFETCH

-include $(OBJS:.o=.d)

.PHONY: clean cleanall tags

clean:
	rm -f *.[od] $(ALL)

cleanall:
	rm -f *.[od] $(ALL) tags cscope.out core
	sudo rm -f perf perf.data

tags:
	ctags -R --extra=f
	cscope -Rb
